#region License
// Copyright 2007-2008 Rory Plaire (codekaizen@gmail.com)
/*
 * This license governs use of the accompanying software. If you use the software, you
 * accept this license. If you do not accept the license, do not use the software.
 * 
 * 1. Definitions
 * The terms "reproduce," "reproduction," "derivative works," and "distribution" have the
 * same meaning here as under U.S. copyright law.
 * A "contribution" is the original software, or any additions or changes to the software.
 * A "contributor" is any person that distributes its contribution under this license.
 * "Licensed patents" are a contributor's patent claims that read directly on its contribution.
 * 
 * 2. Grant of Rights
 * (A) Copyright Grant- Subject to the terms of this license, including the license conditions 
 *     and limitations in section 3, each contributor grants you a non-exclusive, worldwide, 
 *     royalty-free copyright license to reproduce its contribution, prepare derivative works 
 *     of its contribution, and distribute its contribution or any derivative works that you create.
 * (B) Patent Grant- Subject to the terms of this license, including the license conditions and 
 *     limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free 
 *     license under its licensed patents to make, have made, use, sell, offer for sale, import, 
 *     and/or otherwise dispose of its contribution in the software or derivative works of the 
 *     contribution in the software.
 * 
 * 3. Conditions and Limitations
 * (A) No Trademark License- This license does not grant you rights to use any contributors' 
 *     name, logo, or trademarks.
 * (B) If you bring a patent claim against any contributor over patents that you claim are 
 *     infringed by the software, your patent license from such contributor to the software 
 *     ends automatically.
 * (C) If you distribute any portion of the software, you must retain all copyright, patent, 
 *     trademark, and attribution notices that are present in the software.
 * (D) If you distribute any portion of the software in source code form, you may do so only under 
 *     this license by including a complete copy of this license with your distribution. If you 
 *     distribute any portion of the software in compiled or object code form, you may only do so 
 *     under a license that complies with this license.
 * (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no 
 *     express warranties, guarantees or conditions. You may have additional consumer rights under 
 *     your local laws which this license cannot change. To the extent permitted under your local laws, 
 *     the contributors exclude the implied warranties of merchantability, fitness for a particular 
 *     purpose and non-infringement.
 * 
 */
#endregion

// Based initially on JAMA : A Java Matrix Package by 
// National Institute of Standards and Technology (NIST) 
// and The MathWorks, a public-domain work.

using System;
using NPack.Numeric.Interfaces;

namespace NPack.Matrix
{
    /// <summary>
    /// A matrix used to model systems numerically.
    /// </summary>
    /// <typeparam name="T">Type of element in the matrix.</typeparam>
    public class NumericalMatrix<T> : Matrix<T>, INumericalMatrix<T>
        where T : IEquatable<T>, IComparable<T>, IComputable<Double, T>, IConvertible, IFormattable
    {
        /// <summary>
        /// Creates a new <see cref="NumericalMatrix{T}"/>.
        /// </summary>
        /// <param name="rows">Rows in the matrix.</param>
        /// <param name="cols">Columns in the matrix.</param>
        public NumericalMatrix(Int32 rows, Int32 cols)
            : base(MatrixFormat.ColumnMajor, rows, cols) {}

        /// <summary>
        /// Creates a new <see cref="NumericalMatrix{T}"/>.
        /// </summary>
        /// <param name="elements">Elements to use for the matrix.</param>
        public NumericalMatrix(T[][] elements)
            : base(MatrixFormat.ColumnMajor, elements) {}

        /// <summary>
        /// Creates a new <see cref="NumericalMatrix{T}"/> with a specific storage format.
        /// </summary>
        /// <param name="format">Storage format for the matrix, either row-major or column-major.</param>
        /// <param name="elements">Elements to use for the matrix.</param>
        public NumericalMatrix(MatrixFormat format, T[][] elements)
            : base(format, elements) {}

        #region INumericalMatrix<T> Members

        /// <summary>
        /// Returns a matrix which is the solution to the 
        /// <paramref name="b">given matrix</paramref>, if one exists.
        /// </summary>
        /// <param name="b">Matrix to solve this linear system for.</param>
        /// <returns>
        /// The solution, x, to the equation <c>Ax = B</c>, where the 
        /// <see cref="NumericalMatrix{T}"/> is the "A" matrix and the <paramref name="b"/>
        /// parameter is B.
        /// </returns>
        public IMatrix<T> Solve(IMatrix<T> b)
        {
            throw new NotImplementedException("Need to have INumericalMatrix<TComponent, TMatrix>");
            //return MatrixProcessor<T>.Instance.Operations.Solve(this, b);
        }

        /// <summary>
        /// Gets the 1 norm for the matrix.
        /// </summary>
        /// <value>
        /// The maximum column sum.
        /// </value>
        public Double Norm1
        {
            get { return MatrixProcessor<T>.Instance.Operations.OneNorm(this); }
        }

        /// <summary>
        /// Gets the infinity (or max) norm for the matrix.
        /// </summary>
        /// <value>
        /// The maximum row sum.
        /// </value>
        public Double InfinityNorm
        {
            get { return MatrixProcessor<T>.Instance.Operations.InfinityNorm(this); }
        }

        /// <summary>
        /// Gets the Frobenius norm for the matrix.
        /// </summary>
        /// <value>
        /// The square root of sum of squares of all elements.
        /// </value>
        public Double FrobeniusNorm
        {
            get { return MatrixProcessor<T>.Instance.Operations.FrobeniusNorm(this); }
        }

        /// <summary>
        /// Gets the trace of the matrix.
        /// </summary>
        /// <returns>
        /// Sum of the diagonal elements.
        /// </returns>
        public Double Trace
        {
            get { return MatrixProcessor<T>.Instance.Operations.Trace(this); }
        }

        #endregion

        #region IMatrix<T> Members


        public new IMatrix<T> Inverse
        {
            get { throw new NotImplementedException(); }
        }

        public new IMatrix<T> Clone()
        {
            throw new NotImplementedException();
        }

        public new IMatrix<T> GetMatrix(int[] rowIndexes, int startColumn, int endColumn)
        {
            throw new NotImplementedException();
        }

        public new IMatrix<T> Transpose()
        {
            throw new NotImplementedException();
        }

        #endregion

        #region IComparable<IMatrix<T>> Members

        public int CompareTo(IMatrix<T> other)
        {
            throw new NotImplementedException();
        }

        #endregion

        #region IComputable<IMatrix<T>> Members

        public new IMatrix<T> Abs()
        {
            throw new NotImplementedException();
        }

        public new IMatrix<T> Set(double value)
        {
            throw new NotImplementedException();
        }

        #endregion

        #region INegatable<IMatrix<T>> Members

        public new IMatrix<T> Negative()
        {
            throw new NotImplementedException();
        }

        #endregion

        #region ISubtractable<IMatrix<T>> Members

        public IMatrix<T> Subtract(IMatrix<T> b)
        {
            throw new NotImplementedException();
        }

        #endregion

        #region IHasZero<IMatrix<T>> Members

        public new IMatrix<T> Zero
        {
            get { throw new NotImplementedException(); }
        }

        #endregion

        #region IAddable<IMatrix<T>> Members

        public IMatrix<T> Add(IMatrix<T> b)
        {
            throw new NotImplementedException();
        }

        #endregion

        #region IDivisible<IMatrix<T>> Members

        public IMatrix<T> Divide(IMatrix<T> b)
        {
            throw new NotImplementedException();
        }

        #endregion

        #region IHasOne<IMatrix<T>> Members

        public new IMatrix<T> One
        {
            get { throw new NotImplementedException(); }
        }

        #endregion

        #region IMultipliable<IMatrix<T>> Members

        public IMatrix<T> Multiply(IMatrix<T> b)
        {
            throw new NotImplementedException();
        }

        #endregion

        #region IBooleanComparable<IMatrix<T>> Members

        public bool GreaterThan(IMatrix<T> value)
        {
            throw new NotImplementedException();
        }

        public bool GreaterThanOrEqualTo(IMatrix<T> value)
        {
            throw new NotImplementedException();
        }

        public bool LessThan(IMatrix<T> value)
        {
            throw new NotImplementedException();
        }

        public bool LessThanOrEqualTo(IMatrix<T> value)
        {
            throw new NotImplementedException();
        }

        #endregion

        #region IExponential<IMatrix<T>> Members

        public new IMatrix<T> Power(double exponent)
        {
            throw new NotImplementedException();
        }

        public new IMatrix<T> Sqrt()
        {
            throw new NotImplementedException();
        }

        public new IMatrix<T> Log(double newBase)
        {
            throw new NotImplementedException();
        }

        IMatrix<T> IExponential<IMatrix<T>>.Log()
        {
            throw new NotImplementedException();
        }

        public new IMatrix<T> Exp()
        {
            throw new NotImplementedException();
        }

        #endregion
    }
}